package com.handinfo.uimenu.window;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import com.handinfo.engine.AbstractGameScreen;
import com.handinfo.engine.GameManager;
import com.handinfo.game.RoleCombatSkill;
import com.handinfo.uimenu.UIAbstractWindow;
import com.handinfo.uimenu.UIListener;
import com.handinfo.uimenu.UIManager;
import com.handinfo.uimenu.UIMessageBox;
import com.handinfo.uimenu.UIPopmenu;
import com.handinfo.uimenu.UITools;
import com.handinfo.uimenu.UIWindowFactory;
import com.handinfo.util.Tools;
import com.test.touch.GameTouchManager;

public class UISkill extends UIAbstractWindow {
	//
	private final int STATE_LABEL_ONE = 1;// 技能1……
	private final int STATE_LABEL_TWO = 2;// 技能2……
	private final int STATE_TEACH_LEARN = 3;// 技能2……
	//
	private final short TYPE_NULL = 0;// 不做任何处理
	private final short TYPE_LINE = -1;// 绘制线
	private final short TYPE_ARR = -2;// 绘制箭头
	//
	private final int INDEX_TYPE = 0;
	private final int INDEX_RELY = 1;
	//
	private final String TITLE = "技能";
	//
	private int m_rowIndex;
	private int m_colIndex;
	private int m_relY = 0;// 相对Y
	private int m_w_content = 200;
	private int m_h_rect = 200;
	private int m_h_content = 200;
	private boolean m_isControlByLabel;
	//
	private int m_initx_label;// 标签的起始位置
	private int m_initx_content;// 内容的起始位置
	private int m_h_describe;// 显示道具描述的高度
	//
	private String m_str_describe_name;// 名字和等级
	private String m_str_describe_isLearn;// 是否可学
	private String m_str_describe_level;// 等级
	private String m_str_describe_isActive;// 主动
	private String m_str_describe_skillCd;// 技能时间
	private String m_str_describe_sp;// sp 技能cd
	private final String ATT_DESCRIBE_ISACTIVE = "类型";
	private final String ATT_DESCRIBE_CD = "冷却";
	private final String ATT_DESCRIBE_SP = "技能点";

	/**
	 * 标签内容
	 */
	private Image[] m_labels;

	/**
	 * 单元格信息 1：当前类型 2：相对Y 3：
	 */
	private short[][][] m_infos;
	/**
	 * 当前技能
	 */
	private RoleCombatSkill[][] m_skills;

	/**
	 * 当前行是否具有图标
	 */
	private boolean[] m_isRowGotIcons;
	//
	private final int NUM_LABEL_DIS = 2;// 显示的标签数目
	private final int W_LABEL = UITools.W_LABEL_HUGE;// 标签的宽度
	private final int IH_RECT_CONTENT = UITools.IH_RECT_CONTENT;
	private final int W_ITEM = UIManager.IMAGE_ITEM_OPEN.getWidth();
	private final int H_ITEM = UIManager.IMAGE_ITEM_OPEN.getHeight();
	private final int IW_BASE = 4;// 几座的宽度
	private final int IH_BASE = 5;
	private int H_PRE_NONE = 0;// 真实数据行（技能信息行在当前行无图标时的高度）

	private final int W_BASE = W_ITEM + (IW_BASE << 1);// 一个单元格子显示宽度
	private int H_PRE = H_ITEM + (IH_BASE << 1);// 具有图标行的宽度
	private int IW;// 单元格之间的间隙宽度
	private int RW;
	// 标签
	private final int X_LABEL_FIRST = ((UITools.W_BG - (NUM_LABEL_DIS * W_LABEL + (NUM_LABEL_DIS - 1) * UITools.IW_RECT_CONTENT)) >> 1);// 居中显示
	private final int X_ARR_LEFT = X_LABEL_FIRST - (UIManager.IMAGE_LABEL_ARR.getWidth()) - 2;
	private final int X_ARR_RIGHT = UITools.W_BG - X_ARR_LEFT - (UIManager.IMAGE_LABEL_ARR.getWidth());
	// 引导
	private final int W_YINDAO = 70;
	private String[] m_yindao;

	public UISkill(int id) {
		super(id);
		setBounds(UITools.X_BG, UITools.Y_BG, UITools.W_BG, UITools.H_BG);

		m_labels = new Image[] { UIManager.IMAGE_LABEL_SKILL, UIManager.IMAGE_LABEL_JUEXING };
	}

	public static final void gotoSkill() {
		UISkill skill = (UISkill) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_SKILL);
		skill.setWindowStatus(skill.STATE_LABEL_ONE);
		skill.initPos();
	}

	public static final void gotoTeachLearnSkill() {
		UISkill skill = (UISkill) UIWindowFactory.createWindow(UIWindowFactory.WINDOW_SKILL);
		skill.m_labels = new Image[] { UIManager.IMAGE_LABEL_SKILL, UIManager.IMAGE_LABEL_JUEXING };
		skill.setWindowStatus(skill.STATE_TEACH_LEARN);
		skill.initPos();
		//
		RoleCombatSkill[][] skills = skill.m_skills;
		label1: for (int i = 0; i < skills.length; i++) {
			for (int j = 0; j < skills[i].length; j++) {
				if (skills[i][j] == null) {
					continue;
				}
				if (skills[i][j].m_id == UIMain.ID_LEARN_SKILL) {
					// skill.m_rowIndex = i;
					// skill.m_colIndex = j;
					skill.changeIndex(i, j);//
					break label1;
				}
			}
		}
		//
		skill.m_yindao = Tools.getStrArray("单击学习技能", skill.W_YINDAO - 8);
		UIManager.getInstance().addWindow(skill);
	}

	/**
	 * 当技能发生修改需要调用此段代码
	 */
	public static final void update() {
		UISkill skill = (UISkill) UIManager.getInstance().getWindowById(UIWindowFactory.WINDOW_SKILL);
		if (skill == null) {
			return;
		}
		if (skill.m_infos == null) {
			return;
		}
		synchronized (skill) {
			skill.m_skills = skill.initSkills(skill.m_infos);
			skill.setDescribeString();
		}
	}

	protected void actionOnStateChanged() {
		init();
		switch (m_state) {
		case STATE_TEACH_LEARN:
			break;
		default:
			m_yindao = null;
			break;
		}
	}

	private void init() {
		// m_infos = initTestInfos();
		m_infos = initInfos();
		m_skills = initSkills(m_infos);
		m_isRowGotIcons = initRowInfos(m_infos);
		m_infos = initRelY(m_infos, m_isRowGotIcons);
		initRowCols();
	}

	private short[][][] initInfos() {
		switch (m_state) {
		case STATE_LABEL_ONE:
		case STATE_TEACH_LEARN:
			int state =  GameManager.getInstance().m_role.m_vocation[GameManager.getInstance().m_role.m_vocation.length - 1] ;
			if (state >= 10) {
				state = GameManager.getInstance().m_role.m_vocation[GameManager.getInstance().m_role.m_vocation.length - 2] ;
			}
			switch (state) {
			case 1:// 剑客
			{
				int row = 18;
				int col = 5;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 4, 1003);
				results = setData(results, 1, 17, 1006);
				results = setData(results, 2, 0, 12, 1002, 1005);
				results = setData(results, 3, 8, 1004);
				results = setData(results, 4, 0, 1001);
				return results;
			}
			case 2:// 武者
			{
				int row = 18;
				int col = 4;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 5, 1009);
				results = setData(results, 1, 0, 12, 1007, 1011);
				results = setData(results, 2, 0, 17, 1008, 1012);
				results = setData(results, 3, 5, 1010);
				return results;
			}
			case 3:// 道士
			{
				int row = 18;
				int col = 4;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 8, 1016);
				results = setData(results, 0, 17, 1018);
				results = setData(results, 1, 5, 1015);
				results = setData(results, 1, 12, 1017);
				results = setData(results, 2, 0, 1014);
				results = setData(results, 3, 0, 1013);
				return results;
			}
			case 4:// 剑侠
			{
				int row = 33;
				int col = 5;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 19, 27, 1020, 1023);
				results = setData(results, 0, 27, 32, 1023, 1025);
				results = setData(results, 1, 4, 25, 1003, 1022);
				results = setData(results, 0, 15, 17, 1006, 1019);
				results = setData(results, 2, 23, 1024);
				results = setData(results, 2, 29, 1021);
				results = setData(results, 3, 0, 12, 1002, 1005);
				results = setData(results, 4, 0, 1001);
				results = setData(results, 4, 8, 1004);
				return results;
			}
			case 5:// 剑豪
			{
				int row = 33;
				int col = 6;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 4, 1003);
				results = setData(results, 0, 17, 1006);
				results = setData(results, 1, 0, 12, 1002, 1005);
				results = setData(results, 1, 12, 17, 1005, 1026);
				results = setData(results, 2, 8, 32, 1004, 1032);
				results = setData(results, 3, 0, 27, 1001, 1030);
				results = setData(results, 4, 23, 1028);
				results = setData(results, 4, 29, 1031);
				results = setData(results, 5, 19, 25, 1027, 1029);
				return results;
			}
			case 6:// 猛将
			{
				int row = 33;
				int col = 5;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 5, 1009);
				results = setData(results, 1, 0, 12, 1007, 1011);
				results = setData(results, 2, 0, 17, 1008, 1012);
				results = setData(results, 2, 17, 19, 1012, 1034);
				results = setData(results, 2, 19, 29, 1034, 1037);
				results = setData(results, 3, 5, 23, 1010, 1035);
				results = setData(results, 3, 26, 1036);
				results = setData(results, 3, 32, 1038);
				results = setData(results, 4, 17, 1033);
				return results;
			}
			case 7:// 斗士
			{
				int row = 33;
				int col = 5;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 17, 1039);
				results = setData(results, 0, 29, 1045);
				results = setData(results, 1, 5, 23, 1009, 1041);
				results = setData(results, 1, 32, 1044);
				results = setData(results, 2, 0, 12, 1007, 1011);
				results = setData(results, 2, 12, 19, 1011, 1040);
				results = setData(results, 2, 19, 25, 1040, 1042);
				results = setData(results, 2, 27, 1043);
				results = setData(results, 3, 0, 17, 1008, 1012);
				results = setData(results, 4, 5, 1010);
				return results;
			}
			case 8:// 方士
			{
				int row = 33;
				int col = 5;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 17, 1046);
				results = setData(results, 1, 8, 1016);
				results = setData(results, 1, 17, 1018);
				results = setData(results, 1, 19, 1047);
				results = setData(results, 1, 23, 1048);
				results = setData(results, 1, 25, 1049);
				results = setData(results, 1, 27, 1050);
				results = setData(results, 1, 29, 1051);
				results = setData(results, 1, 32, 1052);
				results = setData(results, 2, 5, 1015);
				results = setData(results, 2, 12, 1017);
				results = setData(results, 3, 0, 1014);
				results = setData(results, 4, 0, 1013);
				return results;
			}
			case 9:// 术士
			{
				int row = 33;
				int col = 4;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 8, 1016);
				results = setData(results, 0, 17, 1018);
				results = setData(results, 1, 5, 1015);
				results = setData(results, 1, 12, 1017);
				results = setData(results, 1, 19, 27, 1054, 1057);
				results = setData(results, 2, 0, 23, 1014, 1055);
				results = setData(results, 2, 25, 29, 1056, 1058);
				results = setData(results, 2, 32, 1059);
				results = setData(results, 3, 0, 17, 1013, 1053);
				return results;
			}
			default:
				// throw new IllegalArgumentException("暂时无数据");
				break;
			}
		case STATE_LABEL_TWO:
			switch (GameManager.getInstance().m_role.m_vocation[GameManager.getInstance().m_role.m_vocation.length - 1]) {
			case 10: {
				int row = 15;
				int col = 3;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 0, 14, 1060, 1064);
				results = setData(results, 1, 0, 1062);
				results = setData(results, 2, 0, 1061);
				results = setData(results, 2, 6, 1063);
				return results;
			}
			case 11: {
				int row = 15;
				int col = 2;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 0, 14, 1066, 1068);
				results = setData(results, 1, 0, 6, 1065, 1067);
				return results;
			}
			case 12: {
				int row = 15;
				int col = 2;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 0, 6, 1069, 1071);
				results = setData(results, 1, 0, 14, 1070, 1072);
				return results;
			}
			case 13: {
				int row = 15;
				int col = 1;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 0, 1073);
				results = setData(results, 0, 6, 1074);
				results = setData(results, 0, 14, 1075);
				return results;
			}
			case 14: {
				int row = 15;
				int col = 1;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 0, 1076);
				results = setData(results, 0, 6, 1077);
				results = setData(results, 0, 14, 1078);
				return results;
			}
			case 15: {
				int row = 15;
				int col = 1;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 0, 1079);
				results = setData(results, 0, 6, 1080);
				results = setData(results, 0, 14, 1081);
				return results;
			}
			case 16: {
				int row = 15;
				int col = 1;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 0, 1082);
				results = setData(results, 0, 6, 1083);
				results = setData(results, 0, 14, 1084);
				return results;
			}
			case 17: {
				int row = 15;
				int col = 2;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 0, 1085);
				results = setData(results, 0, 6, 1086);
				results = setData(results, 0, 14, 1088);
				results = setData(results, 1, 6, 1087);
				return results;
			}
			case 18: {
				int row = 15;
				int col = 3;
				short[][][] results = new short[row << 1][col][2];
				results = setData(results, 0, 6, 1091);
				results = setData(results, 1, 0, 1089);
				results = setData(results, 1, 14, 1092);
				results = setData(results, 2, 6, 1090);
				return results;
				}
			}
			return null;
		}
		return null;
	}

	/**
	 * 设置行列数据 具有连接关系的两行同列数据
	 * 
	 * @param temps
	 * @param col
	 * @param row
	 * @param nextRow
	 * @param id
	 * @param nextId
	 */
	private short[][][] setData(short[][][] results, int col, int row, int nextRow, int id, int nextId) {
		if (row >= nextRow) {
			// throw new IllegalArgumentException("行数过小");
			return null;
		}
		int startRow = getDataRow(row);
		int endRow = getDataRow(nextRow);
		results = setRealData(results, col, startRow, id);
		results = setRealData(results, col, endRow, nextId);
		// 连线部分
		startRow++;
		for (int i = startRow; i < endRow; i++) {
			if (i == endRow - 1) {
				results = setRealData(results, col, i, TYPE_ARR);
			} else {
				results = setRealData(results, col, i, TYPE_LINE);
			}
		}
		return results;
	}

	private short[][][] setData(short[][][] results, int col, int row, int id) {
		return setRealData(results, col, getDataRow(row), id);
	}

	/**
	 * 获得真实的数据行
	 * 
	 * @param row
	 * @return
	 */
	private int getDataRow(int row) {
		return row << 1;
	}

	/**
	 * 设置行列数据
	 * 
	 * @param temps
	 * @param col
	 * @param row
	 * @param nextRow
	 * @param id
	 * @param nextId
	 */
	private short[][][] setRealData(short[][][] results, int col, int row, int id) {
		switch (results[row][col][INDEX_TYPE]) {
		case TYPE_NULL:
			results[row][col][INDEX_TYPE] = (short) id;
			break;
		case TYPE_LINE:
		case TYPE_ARR:
			// throw new IllegalArgumentException("当前格子已经被占用 row = " + row +
			// " col = " + col);
			return null;
		default:
			results[row][col][INDEX_TYPE] = (short) id;
			break;
		}
		return results;
	}

	private short[][][] initRelY(short[][][] infos, boolean[] isGotIcons) {
		for (int col = 0; col < infos[0].length; col++) {
			int tempY = 0;
			boolean isSingle = false;
			for (int row = 0; row < infos.length; row++) {
				switch (infos[row][col][INDEX_TYPE]) {
				case TYPE_NULL:
				case TYPE_LINE:
				case TYPE_ARR:
					break;
				default:
					infos[row][col][INDEX_RELY] = (short) tempY;
					// System.out.print("row = " + row + "col = " + col +
					// " H = "+infos[row][col][INDEX_RELY]);
					break;
				}
				isSingle = !isSingle;
				int H = getRowH(isSingle, row, isGotIcons);
				tempY += H;
			}
		}
		return infos;
	}

	private int getRowH(boolean isSingle, int row, boolean[] isGotIcons) {
		int H = 0;
		if (isSingle) {// 真实数据
			H = isGotIcons[row] ? H_PRE : H_PRE_NONE;
		} else {
			H = isGotIcons[row] ? H_PRE : 0;
		}
		return H;
	}

	private RoleCombatSkill[][] initSkills(short[][][] infos) {
		RoleCombatSkill[][] temps = new RoleCombatSkill[infos.length][infos[0].length];
		for (int i = 0; i < infos.length; i++) {
			for (int j = 0; j < infos[i].length; j++) {
				switch (infos[i][j][INDEX_TYPE]) {
				case TYPE_NULL:
				case TYPE_LINE:
				case TYPE_ARR:
					continue;
				default:
					// temps[i][j] =
					// RoleCombatSkill.getTestRoleSkill(infos[i][j][INDEX_TYPE]);
					temps[i][j] = getSkillById(infos[i][j][INDEX_TYPE]);// 根据Id获得技能的对象
					break;
				}
			}
		}
		return temps;
	}

	/**
	 * 根据技能Id从玩家技能列表中获得技能对象
	 * 
	 * @param skillId
	 * @return
	 */
	private RoleCombatSkill getSkillById(short skillId) {
		RoleCombatSkill[] skills = GameManager.getInstance().m_role.m_roleCombatSkill[0];
		if (skills == null || skills.length == 0) {
			return null;
		}
		for (int i = 0; i < skills.length; i++) {
			if (skills[i] == null) {
				continue;
			}
			if (skills[i].m_groupId == skillId) {
				return skills[i];
			}
		}
		return null;
	}

	private boolean[] initRowInfos(short[][][] infos) {
		boolean[] temps = new boolean[infos.length];
		for (int i = 0; i < infos.length; i++) {
			boolean temp = false;
			label1: for (int j = 0; j < infos[i].length; j++) {
				switch (infos[i][j][INDEX_TYPE]) {
				case TYPE_NULL:
				case TYPE_LINE:
					continue;
				default:
					temp = true;
					break label1;
				}
			}
			temps[i] = temp;
		}
		return temps;
	}

	private void initPos() {
		//
		m_initx_label = m_x + ((m_w - (m_labels.length * W_LABEL + (m_labels.length - 1) * UITools.IW_RECT_CONTENT)) >> 1);
		m_initx_content = m_x + UITools.INITX_CONTENT;
		m_h_describe = AbstractGameScreen.FONT_H * 3 + (IH_RECT_CONTENT << 1);
		m_h_rect = UITools.H_RECT - m_h_describe - (UITools.H_LABEL + UITools.IH_RECTS) - UITools.IH_RECTS;
		m_h_content = m_h_rect - (IH_RECT_CONTENT << 1);
		m_w_content = UITools.W_RECT_DRAG;// 计算当前显示道具的宽度，必须是从第一列其实，到最后一列结束
		// Dis
		int size = m_skills[0].length;
		int w_content = m_w_content - (UITools.IW_RECT_CONTENT << 1);
		IW = (w_content - size * W_BASE) / (size - 1);
		RW = W_BASE + IW;
	}

	private void initRowCols() {
		for (int i = 0; i < m_skills.length; i++) {
			for (int j = 0; j < m_skills[i].length; j++) {
				if (m_skills[i][j] != null) {
					changeIndex(i, j);
					return;
				}
			}
		}
	}

	protected void keyLogic() {
		switch (m_state) {
		case STATE_LABEL_ONE:
		case STATE_LABEL_TWO:
			keyLogicOnNormal();
			break;
		case STATE_TEACH_LEARN:
		default:
			keyLogicOnTeach();
			break;
		}
	}

	private void keyLogicOnNormal() {

		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
			close();
			return;
		}
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_D)// *
				|| AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_B)) {
			if (m_state == STATE_LABEL_ONE) {
				if (GameManager.getInstance().m_role.m_vocation[GameManager.getInstance().m_role.m_vocation.length - 1] >= 10) {
					setWindowStatus(STATE_LABEL_TWO);
				} else {
					GameManager.getInstance().addSystemInfo(GameManager.SYSTEM_INFO_TYPE_B, "觉醒还未开启");
				}
			} else {
				setWindowStatus(STATE_LABEL_ONE);
			}
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_UP)) {
			dirUpSkill();
//			registerTouch();
			clearAllRects();
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_DOWN)) {
			dirDownSkill();
//			registerTouch();
			clearAllRects();
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT)) {
			dirLeftSkill();
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT)) {
			dirRightSkill();

		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT) || AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			if (m_skills[m_rowIndex][m_colIndex] == null) {
				return;
			}
			clickItem(m_skills[m_rowIndex][m_colIndex]);
		} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_KEY0)) {
			if (m_skills[m_rowIndex][m_colIndex] != null) {
				GameManager.getInstance().m_game_message.sendSkillDetail(m_skills[m_rowIndex][m_colIndex].m_id);
			}
		}

	}

	private void keyLogicOnTeach() {
		if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT) || AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
			if (m_skills[m_rowIndex][m_colIndex] == null) {
				return;
			}
			clikItemOntaught(m_skills[m_rowIndex][m_colIndex]);
		}
	}

	private UIListener getItemListener(final UIPopmenu popmenu, final RoleCombatSkill skill, final String[] strs) {
		return new UIListener() {

			public void actionPerformed() {
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
					UIManager.getInstance().removeWindow(popmenu);
				} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT) || AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
					int index = popmenu.getCurrentIndex();
					String temp = strs[index];
					if (temp == STR_POP_LEARN) {
						GameManager.getInstance().m_game_message.sendLearnCombatSkill(skill.m_id_nextLvl);
					} else if (temp == STR_POP_REVIEW) {
						GameManager.getInstance().m_game_message.sendSkillDetail(skill.m_id);
					} else if (temp == STR_POP_XIDIAN) {
						clickForget();
					}
					UIManager.getInstance().removeWindow(popmenu);
				}
			}

			private void clickForget() {
				final UIPopmenu subMenu = (UIPopmenu) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
				subMenu.setPopmenus(new String[] { "倒退一级", "全部洗点", "返回" });
				subMenu.addListener(new UIListener() {

					public void actionPerformed() {
						if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
							UIManager.getInstance().removeWindow(subMenu);
						} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT) || AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
							int index = subMenu.getCurrentIndex();
							switch (index) {
							case 0:
								GameManager.getInstance().m_game_message.sendAbolishCombatSkill(skill.m_id);
								break;
							case 1:
								abolishAll();
								break;
							}
							UIManager.getInstance().removeWindow(subMenu);
						}
					}
				});
			}

			private void abolishAll() {
				final UIMessageBox messageBox = (UIMessageBox) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_MESSAGEBOX);
				messageBox.setMessage("是否确定全部洗点");
				messageBox.addListener(new UIListener() {

					public void actionPerformed() {
						if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_RIGHT_SOFT)) {
							UIManager.getInstance().removeWindow(messageBox);
						} else if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT) || AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
							UIManager.getInstance().removeWindow(messageBox);
							GameManager.getInstance().m_game_message.sendAbolishAllCombatSkill();
						}
					}
				});
			}
		};
	}

	private void clikItemOntaught(final RoleCombatSkill skill) {
		final UIPopmenu popmenu = (UIPopmenu) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
		popmenu.setPopmenus(new String[] { STR_POP_LEARN, STR_POP_REVIEW, STR_POP_XIDIAN, STR_POP_BACK });
		popmenu.setStop();
		popmenu.setStopMenu(0);
		popmenu.addListener(new UIListener() {

			public void actionPerformed() {
				if (AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_LEFT_SOFT) || AbstractGameScreen.haveKeyPressed(AbstractGameScreen.GK_A)) {
					UIManager.getInstance().removeWindow(popmenu);
					GameManager.getInstance().m_game_message.sendLearnCombatSkill(skill.m_id_nextLvl);
					// setWindowStatus(STATE_LABEL_ONE) ;//避免引导条件不符合
				}
			}
		});
	}

	private String STR_POP_LEARN = "学习升级";
	private String STR_POP_REVIEW = "查看详情";
	private String STR_POP_XIDIAN = "洗点遗忘";
	private String STR_POP_BACK = "返回";

	private void clickItem(final RoleCombatSkill skill) {
		final UIPopmenu popmenu = (UIPopmenu) UIManager.getInstance().createWindow(UIWindowFactory.WINDOW_POPMENU);
		String[] strs = null;
		if (skill.m_level == skill.m_levelMax) {
			strs = new String[] { STR_POP_REVIEW, STR_POP_XIDIAN, STR_POP_BACK };
		} else if (skill.m_level == 0) {
			strs = new String[] { STR_POP_LEARN, STR_POP_REVIEW, STR_POP_BACK };
		} else {
			strs = new String[] { STR_POP_LEARN, STR_POP_REVIEW, STR_POP_XIDIAN, STR_POP_BACK };
		}
		popmenu.setPopmenus(strs);
		popmenu.addListener(getItemListener(popmenu, skill, strs));
	}

	private boolean dirUpSkill() {
		// 当前列之上所有行
		for (int col = 0; col < m_infos[0].length; col++) {
			for (int i = 0; i < 2; i++) {
				int tempCol = 0;
				if (i == 0) {
					tempCol = m_colIndex - col;
				} else {
					tempCol = m_colIndex + col;
				}
				if (tempCol < 0 || tempCol >= m_infos[0].length) {
					continue;
				}
				for (int row = m_rowIndex - 1; row >= 0; row--) {
					if (m_skills[row][tempCol] == null) {
						continue;
					}
					changeIndex(row, tempCol);// 设置当前选中的技能所在行数
					return false;
				}
			}
		}
		return true;
		//
		// 只往上
		// for (int row = m_rowIndex - 1; row >= 0; row--) {
		// if (m_skills[row][m_colIndex] == null) {
		// continue;
		// }
		// changeIndex(row, m_colIndex);// 设置当前选中的技能所在行数
		// return false;
		// }
		// return true;
	}

	private void dirDownSkill() {
		// 当前列之上所有行
		for (int col = 0; col < m_infos[0].length; col++) {
			for (int i = 0; i < 2; i++) {
				int tempCol = 0;
				if (i == 0) {
					tempCol = m_colIndex - col;
				} else {
					tempCol = m_colIndex + col;
				}
				if (tempCol < 0 || tempCol >= m_infos[0].length) {
					continue;
				}
				for (int row = m_rowIndex + 1; row < m_infos.length; row++) {
					if (m_skills[row][tempCol] == null) {
						continue;
					}
					changeIndex(row, tempCol);// 设置当前选中的技能所在行数
					return;
				}
			}
		}
		// 只往下
		// for (int row = m_rowIndex + 1 ,len= m_skills.length; row < len;
		// row++) {
		// if (m_skills[row][m_colIndex] == null) {
		// continue;
		// }
		// changeIndex(row, m_colIndex);// 设置当前选中的技能所在行数
		// }
	}

	private void dirLeftSkill() {
		for (int i = m_colIndex - 1; i >= 0; i--) {// 当前行优先
			if (m_skills[m_rowIndex][i] != null) {
				changeIndex(m_rowIndex, i);
				return;
			}
		}
		int row = 0;
		for (int i = 1, len = m_skills.length; i < len; i++) {
			// 上一行
			row = m_rowIndex - i;
			if (row >= 0) {
				if (dirHorzonLeft(row, m_colIndex)) {
					return;
				}
			}

			// 一下行
			row = m_rowIndex + i;
			if (row < len) {// 最大行数
				if (dirHorzonLeft(row, m_colIndex)) {
					return;
				}
			}
		}
	}

	private boolean dirHorzonLeft(int row, int col) {
		col = col - 1;
		for (int i = col; i >= 0; i--) {
			if (m_skills[row][col] == null) {
				continue;
			}
			changeIndex(row, col);
			return true;
		}
		return false;
	}

	private void dirRightSkill() {
		for (int i = m_colIndex + 1; i < m_skills[0].length; i++) {// 当前行优先
			if (m_skills[m_rowIndex][i] != null) {
				changeIndex(m_rowIndex, i);
				return;
			}
		}
		int row = 0;
		for (int i = 0, len = m_skills.length; i < len; i++) {
			// 上一行
			row = m_rowIndex - i;
			if (row >= 0) {
				if (dirHorzonRight(row, m_colIndex)) {
					return;
				}
			}

			// 一下行
			row = m_rowIndex + i;
			if (row < len) {// 最大行数
				if (dirHorzonRight(row, m_colIndex)) {
					return;
				}
			}
		}
	}

	private boolean dirHorzonRight(int row, int col) {
		col = col + 1;
		for (int i = col, len = m_infos[0].length; i < len; i++) {
			if (m_skills[row][col] == null) {
				continue;
			}
			changeIndex(row, col);
			return true;
		}
		return false;
	}

	private void changeIndex(int rowIndex, int colIndex) {
		// 顶部小于
		while (m_relY + m_infos[rowIndex][colIndex][INDEX_RELY] <= 0) {
			m_relY++;
		}
		while ((m_relY + m_infos[rowIndex][colIndex][INDEX_RELY] + H_PRE) >= m_h_content) {
			m_relY--;
		}
		m_rowIndex = rowIndex;
		m_colIndex = colIndex;
		//
		setDescribeString();
	}

	private void setDescribeString() {
		RoleCombatSkill skill = m_skills[m_rowIndex][m_colIndex];
		if (skill == null) {
			return;
		}
		m_str_describe_name = skill.m_name;
		m_str_describe_level = new StringBuffer(20).append("(").append(skill.m_level).append("/").append(skill.m_levelMax).append(")").toString();
		m_str_describe_isLearn = skill.m_canLearn ? "可学" : "不可学";
		if (skill.m_canLearn) {
			if (skill.m_level == skill.m_levelMax) {
				m_str_describe_isLearn = "最高级";
			} else {
				m_str_describe_isLearn = "可学";
			}
		} else {
			m_str_describe_isLearn = "不可学";
		}
		m_str_describe_isActive = skill.isPasstive() ? "被动" : "主动";
		if (skill.m_cd > 0) {
			m_str_describe_skillCd = String.valueOf(skill.m_cd / GameManager.FRAME_PER_SECOND);
		} else {
			m_str_describe_skillCd = null;
		}
		m_str_describe_sp = String.valueOf(GameManager.getInstance().m_role.m_combatSkillPoint);
	}

	protected void paintContent(Graphics g) {
		UITools.paintBackGround(g, m_x, m_y, m_w, m_h, TITLE, ALERT, true, true);
		int tempY = m_y + UITools.INITY_CONTENT;
//		paintLabelArr(g, m_x + X_ARR_LEFT, tempY, true);
		paintLabels(g, m_initx_label, tempY, W_LABEL);
//		paintLabelArr(g, m_x + X_ARR_RIGHT, tempY, false);
		tempY += (IH_RECT_CONTENT + UITools.H_LABEL);
		int initY = tempY;
		paintItems(g, m_initx_content, tempY, m_w_content, m_h_rect);
		tempY += (m_h_rect + IH_RECT_CONTENT);
		paintDescribe(g, m_initx_content, tempY, m_w_content, m_h_describe);
		tempY += (m_h_describe + IH_RECT_CONTENT);
		paintScroll(g, m_x + UITools.X_DRAG, initY, m_h_rect);
		paintYindao(g);
		paintFocus(g);
	}

	private String ALERT = "查看技能";
	private int m_x_fos = -1000;
	private int m_y_fos = -1000;

	private void paintLabelArr(Graphics g, int x, int y, boolean isLeft) {
		boolean isLight = true;
		if (isLeft) {
			isLight = !(m_state == STATE_LABEL_ONE);
		} else {
			isLight = !(m_state == STATE_LABEL_TWO);
		}
		UITools.paintLabelArr(g, x, y, isLeft, isLight);
	}

	/**
	 * 绘制标签
	 * 
	 * @param g
	 * @param x
	 * @param y
	 */
	private void paintLabels(Graphics g, int x, int y, int w) {
		if (m_labels == null) {
			return;
		}
		int tempX = x;
		for (int i = 0; i < m_labels.length; i++) {
			UITools.paintLabelImage(g, tempX, y, w, UITools.H_LABEL, m_labels[i], i + STATE_LABEL_ONE == m_state);
			tempX += (w + UITools.IW_RECT_CONTENT);
		}
	}

	private final String SECOND = "秒";

	/**
	 * 绘制技能的描述
	 */
	private void paintDescribe(Graphics g, int x, int y, int w, int h) {
		UITools.paintContentRect(g, x, y, w, h);
		int initX = x + UITools.IW_RECT_CONTENT;
		int initY = y + UITools.IH_RECT_CONTENT;
		int tempX = initX;
		int tempY = initY;
		int endX = x + w - 4;
		if (m_str_describe_name != null) {
			g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
			g.drawString(m_str_describe_name, tempX, tempY, 0);
			tempX += AbstractGameScreen.s_font.stringWidth(m_str_describe_name);
		}
		tempX += 5;
		if (m_str_describe_level != null) {
			g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
			g.drawString(m_str_describe_level, tempX, tempY, 0);
			tempX += AbstractGameScreen.s_font.stringWidth(m_str_describe_level);
		}
		//
		tempX = initX;
		tempY += AbstractGameScreen.FONT_H;
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_YESS));
		if (m_str_describe_isActive != null) {
			g.drawString(ATT_DESCRIBE_ISACTIVE, tempX, tempY, 0);
			tempX += AbstractGameScreen.s_font.stringWidth(ATT_DESCRIBE_ISACTIVE);
			tempX += 5;
			g.drawString(m_str_describe_isActive, tempX, tempY, 0);
			tempX += AbstractGameScreen.s_font.stringWidth(m_str_describe_isActive);
		}
		tempX += 15;
		if (m_str_describe_skillCd != null) {
			g.drawString(ATT_DESCRIBE_CD, tempX, tempY, 0);
			// tempX += AbstractGameScreen.s_font.stringWidth(ATT_DESCRIBE_CD);
			tempX = endX;
			g.drawString(SECOND, endX, tempY, Graphics.RIGHT | Graphics.TOP);
			tempX -= (AbstractGameScreen.s_font.stringWidth(SECOND) + 1);
			g.drawString(m_str_describe_skillCd, tempX, tempY, Graphics.RIGHT | Graphics.TOP);

		}
		tempX = initX;
		tempY += AbstractGameScreen.FONT_H;
		g.setColor(UIManager.getPaletteColor(UIManager.COLOR_WORD_NOS));
		if (m_str_describe_sp != null) {
			g.drawString(ATT_DESCRIBE_SP, tempX, tempY, 0);
			tempX += AbstractGameScreen.s_font.stringWidth(ATT_DESCRIBE_SP);
			tempX += 5;
			g.drawString(m_str_describe_sp, tempX, tempY, 0);
		}
		tempX += 25;
		if (m_str_describe_isLearn != null) {
			if (m_skills[m_rowIndex][m_colIndex] != null) {
				if (m_skills[m_rowIndex][m_colIndex].m_canLearn) {
					if (m_skills[m_rowIndex][m_colIndex].m_level == m_skills[m_rowIndex][m_colIndex].m_levelMax) {
						g.setColor(Tools.YELLOW);
					} else {
						g.setColor(Tools.GREEN);
					}
				} else {
					g.setColor(Tools.RED);
				}
				g.drawString(m_str_describe_isLearn, endX, tempY, Graphics.RIGHT | Graphics.TOP);
			}
		}
	}

	private void paintScroll(Graphics g, int x, int y, int h) {
		if (m_skills == null) {
			return;
		}
		int plan = 0;
		if (m_rowIndex == m_skills.length - 2) {
			plan = 100;
		} else {
			plan = (int) ((m_rowIndex * 100) / m_skills.length);
		}
		UITools.paintScrollBar(g, x, y, h, plan);
	}

	private void paintItems(Graphics g, int x, int y, int w, int h) {
		UITools.paintContentRect(g, x, y, w, h);
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		int tempX = x + UITools.IW_RECT_CONTENT;
		g.setClip(tempX, y + IH_RECT_CONTENT, w - (UITools.IW_RECT_CONTENT << 1), h - (IH_RECT_CONTENT << 1));
		boolean isSingle = true;// 是否是单行
		boolean isNull = getRects()==null || getRects().size()==0;
		int[][] rect = null;
		int rectIdx=0;
		if (isNull) {
			rect = new int[5*5][];
		}
		for (int i = 0; i < m_infos[0].length; i++) {
			int tempY = y + m_relY + IH_RECT_CONTENT + IH_BASE;
			boolean isLighten = true;//
			for (int j = 0; j < m_infos.length; j++) {
				int H = getRowH(isSingle, j, m_isRowGotIcons);
				if (H != 0) {
					switch (m_infos[j][i][INDEX_TYPE]) {
					case TYPE_NULL:// 无
						break;
					case TYPE_LINE:
						paintLines(g, tempX, tempY, W_BASE, H, isLighten);
						break;
					case TYPE_ARR:
						paintArr(g, tempX, tempY, W_BASE, H, isLighten);
						break;
					default:
						// 技能
						boolean isFocused = m_rowIndex == j && m_colIndex == i;
						paintSkill(g, tempX, tempY, W_BASE, H, m_skills[j][i], isFocused && !m_isControlByLabel);
						if (rect != null) {
							if (tempY > y-H && tempY < y + IH_RECT_CONTENT + h - (IH_RECT_CONTENT << 1)) {
								System.out.println("add rectidx="+rectIdx+", x = "+tempX+" ,y="+tempY);
								mskillIdx[rectIdx] = new int[]{j, i};
								rect[rectIdx++] = new int[]{tempX, tempY, W_BASE, H};
							}
						}
						// 连线，箭头的箭头
						if (isLighten == true) {// 默认都是true,若之前有一个为false，则不再进行判断
							isLighten = isLighten(j, i, m_skills);
						}
						break;
					}
				}
				//
				tempY += H;
				isSingle = !isSingle;
			}
			tempX += RW;
		}
		g.setClip(clipX, clipY, clipW, clipH);
		if (rect != null) {
			registerTouch1(rect);
		}
	}

	private void paintYindao(Graphics g) {
		if (m_state != STATE_TEACH_LEARN) {
			return;
		}
		int clipX = g.getClipX();
		int clipY = g.getClipY();
		int clipW = g.getClipWidth();
		int clipH = g.getClipHeight();
		g.setClip(0, 0, AbstractGameScreen.SCREEN_WIDTH, AbstractGameScreen.SCREEN_HEIGHT);
		int iw = 4;
		UITools.paintYindao(g, m_yindao, m_x_fos + UITools.W_BAG + iw, m_y_fos + UITools.H_BAG + iw, W_YINDAO, 1, UITools.W_BAG + (iw << 1), UITools.H_BAG + (iw << 1));
		g.setClip(clipX, clipY, clipW, clipH);
	}

	/**
	 * 下一技能是否可以学习
	 * 
	 * @param row
	 * @param col
	 * @param skill
	 * @return
	 */
	private boolean isLighten(int row, int col, RoleCombatSkill[][] skill) {
		int lv = GameManager.getInstance().m_role.m_lv;
		for (int i = row + 1; i < skill.length; i++) {
			if (skill[i][col] == null) {
				continue;
			}
			if (lv >= i) {// 当前玩家达到金额共学习等级
				return true;
			} else {
				return false;
			}
		}
		return false;
	}

	private void paintSkill(Graphics g, int x, int y, int w, int h, RoleCombatSkill skill, boolean isSel) {
		if (skill == null) {
			return;
		}
		int initX = x + ((w - W_ITEM) >> 1);
		int initY = y + ((h - H_ITEM) >> 1);
		if (isSel) {
			m_x_fos = initX;
			m_y_fos = initY;
		}
		int tempX = initX - IW_BASE;
		int tempY = initY - IH_BASE;
		g.drawImage(UIManager.IMAGE_JINENGBASE, tempX, tempY, 0);
		Tools.drawRegion(g, UIManager.IMAGE_JINENGBASE, tempX + 14, tempY, Tools.TRANS_H, 0);
		tempX = initX;
		tempY = initY;
		g.drawImage(UIManager.IMAGE_ITEM_CLOSE, tempX, tempY, 0);
		skill.drawIcon(g, tempX + 1, tempY + 1, 0);
		if (skill.m_canLearn) {// 能学
			int TEMPW = UIManager.IMAGE_ADD.getWidth() >> 1;
			int TEMPH = UIManager.IMAGE_ADD.getHeight();
			int TEMPADDX = tempX + W_ITEM - TEMPW;
			int TEMPADDY = tempY + H_ITEM - 6;
			//
			if (UIManager.TIME % 6 < 3) {
				g.drawRegion(UIManager.IMAGE_ADD, 0, 0, TEMPW, TEMPH, Tools.TRANS_H, TEMPADDX, TEMPADDY, Tools.LEFT_VCENTER);
			} else {
				g.drawRegion(UIManager.IMAGE_ADD, TEMPW, 0, TEMPW, TEMPH, Tools.TRANS_H, TEMPADDX, TEMPADDY, Tools.LEFT_VCENTER);
			}
		}
	}

	private void paintFocus(Graphics g) {
		UITools.paintFocusBox(g, m_x_fos, m_y_fos, W_ITEM, H_ITEM);
	}

	/**
	 * 绘制连接部分
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	private void paintLines(Graphics g, int x, int y, int w, int h, boolean isLight) {
		int tempW = 4;
		int tempX = ((w - tempW) >> 1) + x;
		int tempY = y;
		int color = isLight ? COLOR_INNER_YELLOW : COLOR_INNER_GRAY;
		g.setColor(color);
		g.fillRect(tempX + 1, tempY, tempW, h);
		int endY = y + h;
		g.setColor(0x4d0202);// 边缘
		g.drawLine(tempX, tempY, tempX, endY);
		tempX += tempW;
		g.drawLine(tempX, tempY, tempX, endY);
	}

	private final int COLOR_INNER_GRAY = 0x929386;
	private final int COLOR_OUT_RED_DARK = 0x4d0202;
	private final int COLOR_INNER_YELLOW = Tools.YELLOW;

	/**
	 * 绘制箭头
	 * 
	 * @param g
	 * @param x
	 * @param y
	 * @param w
	 * @param h
	 */
	private void paintArr(Graphics g, int x, int y, int w, int h, boolean isLight) {
		int tempH = 10;
		int tempW = 15;
		int startX = x + ((w - tempW) >> 1) + 1;
		int endX = startX + tempW;
		int startY = y + tempH;
		int lastX = x + (w >> 1);
		int lastY = y + h - 2;
		g.setColor(COLOR_OUT_RED_DARK);
		g.drawLine(startX, startY, endX, startY);
		g.drawLine(startX, startY, lastX, lastY);
		g.drawLine(endX, startY, lastX, lastY);
		startX += 1;
		startY += 1;
		endX -= 1;
		lastY -= 1;
		int color = isLight ? COLOR_INNER_YELLOW : COLOR_INNER_GRAY;
		g.setColor(color);
		g.fillTriangle(startX, startY, endX, startY, lastX, lastY);
		//
		paintLines(g, x, y, w, tempH, isLight);
	}
////////////////////////////
	int[][] mlabel,mskill,mskillIdx = new int[5*6][];
	protected void registerTouch1(int[][] rect) {
		clearAllRects();
		registerNormalSoft();
		
//		int tempY = m_y + UITools.INITY_CONTENT;
//		paintLabelArr(g, m_x + X_ARR_LEFT, tempY, true);
//		paintLabels(g, m_initx_label, tempY, W_LABEL);
		mlabel = new int[][]{
				{166,39,71,20},
				{240,39,71,20},
				//
				{446,61,20,35},
				{446,185,20,35},
		};
		initTouchRect(mlabel);
		initTouchRect(mskill = rect);
///////////////////////////////
//		tempY += (IH_RECT_CONTENT + UITools.H_LABEL);
////		paintItems(g, m_initx_content, tempY, m_w_content, m_h_rect);
//		if (m_infos == null || m_infos.length == 0)
//			return;
//		mskill = new int[m_infos[0].length*m_infos.length][];
//		int tempX = m_initx_content + UITools.IW_RECT_CONTENT;
//		boolean isSingle = true;// 是否是单行
//		for (int i = 0; i < m_infos[0].length; i++) {
//			tempY = tempY + m_relY + IH_RECT_CONTENT + IH_BASE;
//			for (int j = 0; j < m_infos.length; j++) {
//				int H = getRowH(isSingle, j, m_isRowGotIcons);
//				if (H != 0) {
//					switch (m_infos[j][i][INDEX_TYPE]) {
//					case TYPE_NULL:// 无
//						break;
//					case TYPE_LINE:
////						paintLines(g, tempX, tempY, W_BASE, H, isLighten);
//						break;
//					case TYPE_ARR:
////						paintArr(g, tempX, tempY, W_BASE, H, isLighten);
//						break;
//					default:
//						mskill[i*m_infos[0].length+j] = new int[]{tempX, tempY, W_BASE, H};
////						// 技能
////						boolean isFocused = m_rowIndex == j && m_colIndex == i;
////						paintSkill(g, tempX, tempY, W_BASE, H, m_skills[j][i], isFocused && !m_isControlByLabel);
////						// 连线，箭头的箭头
////						if (isLighten == true) {// 默认都是true,若之前有一个为false，则不再进行判断
////							isLighten = isLighten(j, i, m_skills);
////						}
//						break;
//					}
//				}
//				//
//				tempY += H;
//				isSingle = !isSingle;
//			}
//			tempX += RW;
//		}
//		initTouchRect(mskill);
	}

	protected void onTouchRect(int[][] rect, int touchid) {
		if (mskill == rect) {
			changeIndex(mskillIdx[touchid][0], mskillIdx[touchid][1]);
			GameTouchManager.keyPressedFire();
		} else {
			switch(touchid) {
			case 0:
				GameTouchManager.keyPressedStar();
				break;
			case 1:
				GameTouchManager.keyPressedPound();
				break;
			case 2:
				GameTouchManager.keyPressedDir(1);
				break;
			case 3:
				GameTouchManager.keyPressedDir(3);
				break;
			}
		}
	}

	
}
